package com.zoshine.zzg.controller;

import com.github.pagehelper.PageInfo;
import com.zoshine.zzg.base.BaseResponse;
import com.zoshine.zzg.pojo.TransferAccounts;
import com.zoshine.zzg.respons.AppResponse;
import com.zoshine.zzg.service.TransferAccountsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**转账控制层
 * @author 田沛凌
 * @time 2017/8/18 11:34
 */
@RestController
@RequestMapping(value = "transferAccounts", method = RequestMethod.POST)
public class TransferAccountsController extends BaseController{

    public TransferAccountsService transferAccountsService;
    @Autowired
    public void setTransferAccountsService(TransferAccountsService transferAccountsService) {
        this.transferAccountsService = transferAccountsService;
    }
    /**
     * 新增转账表
     * @param transferAccounts；
     */
    @RequestMapping("/addTransferAccounts")
    public BaseResponse addTransferAccounts(TransferAccounts transferAccounts){
        transferAccountsService.add(transferAccounts);
        return AppResponse.OK;
    }
    /**
     * 获取转账表
     * @param id 转账表id
     * @return 转账表
     */
    @RequestMapping("/getTransferAccounts")
    public BaseResponse getTransferAccounts(Long id){
        TransferAccounts transferAccounts = transferAccountsService.get(id);
        return new AppResponse(transferAccounts);
    }
    /**
     * 查询转账表(分页)
     * @param transferAccounts；
     * @return 转账表集合
     */
    @RequestMapping("/pageTransferAccounts")
    public BaseResponse pageTransferAccounts(TransferAccounts transferAccounts){
        List<TransferAccounts> list = transferAccountsService.list(transferAccounts);
        return new AppResponse(new PageInfo<>(list));
    }
    /**
     * 删除转账表
     * @param id 转账表id
     */
    @RequestMapping("/delTransferAccounts")
    public BaseResponse delTransferAccounts(Long id){
        transferAccountsService.del(id);
        return AppResponse.OK;
    }
    /**
     * 修改转账表
     * @param transferAccounts；
     */
    @RequestMapping("/editTransferAccounts")
    public BaseResponse editTransferAccounts(TransferAccounts transferAccounts){
        transferAccountsService.edit(transferAccounts);
        return AppResponse.OK;
    }

}
